import Vue from "vue";
import Vuex from "vuex";

Vue.use(Vuex);

export default new Vuex.Store({
  state: {
    userName: localStorage.getItem("userName"),
    userType: localStorage.getItem("userType"),
    studentInfomation:JSON.parse(localStorage.getItem("studentInfomation")),//将字符串'true'转为true,false
    teacherInfomation:JSON.parse(localStorage.getItem("teacherInfomation"))
  },
  mutations: {
    loginOk(state, local) {
      state.userName = local.userName;
      state.userType = local.userType;
    },
    setStudentInfomation(state,studentInfomation){
      state.studentInfomation=studentInfomation
    },
    setTeacherInfomation(state,teacherInfomation){
      state.teacherInfomation=teacherInfomation
    }
  },
  actions: {},
  modules: {},
});
